package linkedlist;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void main(String[] args) {
        LinkedList<Integer> list = new LinkedList<>();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        System.out.println("=======1=======");
        System.out.println(list);
        System.out.println("========2======");
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        System.out.println("======3========");
        for(int x : list) {
            System.out.print(x+" ");
        }
        System.out.println();
        System.out.println("=======4=======");
        Iterator<Integer> it =  list.iterator();
        while (it.hasNext()) {
            System.out.print(it.next()+" ");//i++;  i = i+1
        }
        System.out.println();
        System.out.println("=======5=======");

        ListIterator<Integer> lit = list.listIterator();
        while (lit.hasNext()) {
            System.out.print(lit.next()+" ");//i++;  i = i+1
        }
        System.out.println();
        System.out.println("=======6=======");

        ListIterator<Integer> lit2 = list.listIterator(list.size());
        while (lit2.hasPrevious()) {
            System.out.print(lit2.previous()+" ");
        }
        System.out.println();
    }

    public static void main2(String[] args) {
        LinkedList<Integer> list = new LinkedList<>();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);

        LinkedList<String> list3 = new LinkedList<>();

        ArrayList<Integer> list1 = new ArrayList<>();

        LinkedList<Integer> list2 = new LinkedList<>(list1);
        list2.add(0,10);

        list2.addAll(list);


    }

    public static void main1(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addLast(4);
        myLinkedList.addLast(4);
        myLinkedList.addLast(4);
        myLinkedList.addLast(4);
        //myLinkedList.addFirst(14);
        //myLinkedList.addIndex(13,99);
        myLinkedList.display();
        myLinkedList.removeAllKey(4);
        System.out.println("======");
        myLinkedList.display();

        //System.out.println(myLinkedList.size());
        //System.out.println(myLinkedList.contains(31));
    }
}
